package com.bw.module_merchant.vm

import android.util.Log

import com.bw.lib_common.vm.BaseViewModel
import com.bw.module_home.api.MerchantApiServer
import com.bw.module_home.model.MerchantRepository
import com.bw.module_home.model.MerchantResultData
import com.bw.module_merchant.entity.EnterpriseRecordEntity

import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class EnterpriseRecordDetailViewModel @Inject constructor(
    private val mService: MerchantApiServer
) : BaseViewModel<MerchantRepository, MerchantResultData<EnterpriseRecordEntity>>() {


    fun getDetail(id:Int) {
        mViewModelScope.launch {
            try {
                val result = mService.getMerchantApplicationDetail(id)
                val res = MerchantResultData(
                    state = result.state,
                    data = result.data,
                    msg = result.msg
                )

                mSuccessLiveData.postValue(res)
            }catch (e:Exception){
                Log.d("uuu", "getMerchantRecordList: ${e.message}")
                mErrorLiveData.value = e.message
            }
        }
    }
}